package com.yogee.topseller.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yogee.topseller.R;
import com.yogee.topseller.activity.PayActivity;
import com.yogee.topseller.bean.XwzxBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @auathor ${XiaoJianghong}
 * @date 2017/6/26.
 */

public class XzcfAdapter extends RecyclerView.Adapter<XzcfAdapter.ItemHolder> {

    private Context context;
    private List<XwzxBean> beans = new ArrayList<>();


    private PayActivity.Listener listener;

    public XzcfAdapter(Context context) {
        this.context = context;
    }

    public void addData(List<XwzxBean> beans) {
        this.beans = beans;
        notifyDataSetChanged();
    }

    public void setListener(PayActivity.Listener listener){
        this.listener = listener;
    }

    @Override
    public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_xzcf,null,false);
        return new ItemHolder(view);
    }

    @Override
    public void onBindViewHolder(ItemHolder holder, final int position) {
        XwzxBean bean = beans.get(position);
//        holder.tv_title.setText(beans.get(position).getTitle());
        RecyclerView.LayoutManager manager = new LinearLayoutManager(context);
//        manager.setAutoMeasureEnabled(true);
        holder.rv_wenjian.setLayoutManager(manager);
        XzcfItemAdapter fengxianItemAdapter = new XzcfItemAdapter(context);
        holder.rv_wenjian.setAdapter(fengxianItemAdapter);
        XwzxBean.Wenjian wj1 = new XwzxBean.Wenjian();
        List<XwzxBean.Wenjian> wenjianList = new ArrayList<>();
        wenjianList.add(wj1);
        wenjianList.add(wj1);
//        fengxianItemAdapter.addData(wenjianList);
    }

    @Override
    public int getItemCount() {
        return beans == null ? 0 : beans.size();
    }

    class ItemHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_title)
        TextView tv_title;
        @BindView(R.id.rv_wenjian)
        RecyclerView rv_wenjian;
        public ItemHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }


}